<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class home_controller extends public_controller
{
    public function index()
    {
        $titles = $this->information->get_all_ticket_type();
        $data = array();
        foreach($titles as $title){
            $data[] = array(
                'ticket_title' => $title->ticket_title,
                'sum_number' => $this->information->get_check_in_count($title->ticket_title)->cnt
            );

        }

        $this->view_data['summary'] = array_to_object($data);
        $this->view_data['wrongCardNumber'] = $this->check_in_log->get_wrong_number()->sumCount;
        $this->view_data['rightCardNumber'] = count($this->information->get_elements_checked_in());

        $this->load_view('home');
    }

//    IMPORT DATA FROM arr TO import_arr
    function import_item($arr,$import_arr)
    {
        foreach($arr as $item)
        {
            $import_arr[] = array(
                'title' => $item->title,
                'url' => $item->url,
                'modified_date' => $item->modified_date
            );
        }
        return $import_arr;
    }

    public function update_summary(){
        $summary = $this->information->get_summary_info();
        echo json_encode($summary);
    }

    public function get_menu_code()
    {
        return 'HOME';
    }

    public function get_english_link()
    {
        return base_url().'home';
    }

    public function get_vietnam_link()
    {
        return base_url().'trang-chu';
    }
}